package sz.szsmk.citizencard.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.chenenyu.router.annotation.Route;

import sz.szsmk.citizencard.DaggerApplication;
import sz.szsmk.citizencard.R;
import sz.szsmk.citizencard.databinding.NoticeDetailActivityBinding;
import sz.szsmk.citizencard.ioc.Compontent.DaggerCommonActivityComponent;
import sz.szsmk.citizencard.model.network.bean.response.NoticeDetailRes;
import sz.szsmk.citizencard.mvp.contract.INoticeDetailContact;
import sz.szsmk.citizencard.mvp.presenter.NoticeDetailPresenter;
import sz.szsmk.citizencard.ui.base.IBaseActivity;

/**
 * Copyright (c)2018
 * author: zdh
 * created on: 2018/8/14 11:42
 * description:
 */
@Route("noticedetail")
public class NoticeDetailActivity extends IBaseActivity<NoticeDetailPresenter, NoticeDetailActivityBinding>
        implements INoticeDetailContact.INoticeDetailView, View.OnClickListener {

    @Override
    protected int attachLayoutRes() {
        return R.layout.notice_detail_activity;
    }

    @Override
    protected void initInjector() {

        DaggerCommonActivityComponent.builder().appCompontent(DaggerApplication.getAppComponent())
                .build().inject(this);
    }

    @Override
    protected void initViews() {
        Intent intent = getIntent();
        String detailId = intent.getStringExtra("detailId");
        if (detailId != null) {
            mPresenter.getNoticeDetail(detailId);
        }
        dataBinding.titleLayout.back.setOnClickListener(this);
        dataBinding.titleLayout.bjTv.setText("详情");
//        bjTv.setText("详情");

    }

    @Override
    protected void updateViews() {

    }

    @Override
    public void getNoticeDetailError(String response) {

    }

    @Override
    public void getNoticeDetailSuccess(NoticeDetailRes response) {
        dataBinding.noticeDetailTime.setText(response.getCreateTime());
        dataBinding.noticeDetailTitle.setText(response.getTitle());
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.back) {
            finish();
        }
    }
}
